#include "MainWindow.h"
#include "MonitorDeviderWidget.h"
#include "ui_MainWindow.h"

MainWindow::MainWindow(QWidget *parent)
  : QMainWindow(parent)
  , ui(new Ui::MainWindow) {
    ui->setupUi(this);
    setCentralWidget(new MonitorDeviderWidget(this));

    connect(ui->action_divider_1, &QAction::triggered, this, [this] { divider(1); });
    connect(ui->action_divider_4, &QAction::triggered, this, [this] { divider(4); });
    connect(ui->action_divider_8, &QAction::triggered, this, [this] { divider(8); });
    connect(ui->action_divider_13, &QAction::triggered, this, [this] { divider(13); });
    connect(ui->action_divider_16, &QAction::triggered, this, [this] { divider(16); });
    connect(ui->action_next, &QAction::triggered, this, [this] {
        auto w = qobject_cast<MonitorDeviderWidget *>(centralWidget());
        w->nextSelectedItem();
    });
}

MainWindow::~MainWindow() {
    delete ui;
}

void MainWindow::divider(int number) {
    auto w = qobject_cast<MonitorDeviderWidget *>(centralWidget());
    w->setMode(MonitorDeviderWidget::DeviderMode(number));
}
